<template>
  <div class="payment">
    <div class="qr-box">
      <div class="qr-img">
        <div ref="cbcCode"></div>
      </div>
    </div>
    <div class="info">
      <div class="info-item">
        <span class="rowLabel">{{ $t("chain_type") }}:</span>
        <span class="rowValue">{{ chain_type }}</span>
      </div>
      <!-- <div class="info-item">
        <span class="rowLabel">USDT充值账号:</span>
        <span class="rowValue">TRC20</span>
      </div> -->
      <div class="info-item">
        <span class="rowLabel">{{ $t("rechargeAddress") }}:</span>
        <span class="rowValue"
          >{{ address }}
          <span class="textBtn" @click="copy">{{ $t("copy") }}</span>
        </span>
      </div>
      <div class="info-item">
        <span class="rowLabel">{{ $t("USDTamount") }}:</span>
        <span class="rowValue">{{ amount }}</span>
      </div>
      <!-- <div class="info-item">
        <span class="rowLabel">最终到账金额为:</span>
        <span class="rowValue">{{ amount }}</span>
      </div> -->
    </div>
    <!-- <div class="headcard" style="height: 100%">
      <div class="qr-box">
        <div class="qr-title">{{ $t("paymentTips1") }}</div>
        <div class="qr-img">
          <div ref="cbcCode"></div>
        </div>
        <div class="qr-title">{{ $t("PaymentAddress") }}</div>
        <div class="pay-way-box">
          <div class="pay-way address-box">
            <div class="pay-item top">
              <div class="address">
                {{ address }}
              </div>
            </div>
          </div>
        </div>
        <div class="btn" @click="copy">{{ $t("CopyAddress") }}</div>
      </div>
    </div> -->
  </div>
</template>
<script>
import QRCode from "qrcodejs2";
import { copyText } from "@/utils/common";
export default {
  name: "payment",
  data() {
    return {
      payWayTitle: "",
      chain_type: "",
      amount: "",
      address: "",
    };
  },
  created() {
    this.init();
  },
  methods: {
    copy() {
      copyText(this.address);
      this.$message.success(this.$t("copySuccess"));
    },
    init() {
      const { pay_channel, chain_type, amount, address } = JSON.parse(
        this.$route.params.item
      );
      this.chain_type = chain_type;
      this.amount = amount;
      this.address = address;
      pay_channel.includes("USDT")
        ? (this.payWayTitle = "USDT")
        : (this.payWayTitle = this.$t("FastPay"));
      this.$nextTick(() => {
        new QRCode(this.$refs.cbcCode, {
          text: address,
          width: 200,
          height: 200,
          colorDark: "#000000",
          colorLight: "#ffffff",
          correctLevel: QRCode.CorrectLevel.H,
        });
      });
    },
  },
};
</script>
<style lang="less" scoped>
.payment {
  width: 100%;
  height: 240px;
  padding: 20px;
  display: flex;
  justify-content: start;
  align-items: center;
  .qr-box {
    width: 200px;
    .qr-img {
      width: 100%;
      margin: 0 auto;
      display: flex;
      justify-content: center;
    }
  }
  .info {
    flex: 1;
    height: 100%;
    background: #f4f6f9;
    margin-left: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-items: start;
    .info-item {
      flex: 1;
      display: flex;
      justify-content: start;
      align-items: center;
      .rowLabel {
        display: inline-block;
        min-width: 130px;
        font-size: 14px;
      }
      .rowValue {
        margin-left: 10px;
        display: flex;
        justify-content: start;
        align-items: center;
        font-size: 14px;
        .textBtn {
          display: inline-block;
          width: 60px;
          line-height: 20px;
          background-color: #513216;
          border-radius: 10px;
          font-size: 12px;
          color: #fff;
          margin-left: 5px;
          text-align: center;
          cursor: pointer;
        }
      }
    }
  }
}
.address-box {
  padding: 25px !important;
}
.pay-way-box {
  margin: 30px;
  .pay-way {
    // background: #ced4f8;
    background-color: #f9f3dd;
    // display: flex;
    justify-content: space-between;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    .top {
      margin-bottom: 20px;
    }
    .bottom {
      margin-top: 20px;
    }
    .pay-item {
      display: flex;
      justify-content: space-between;
      height: 100%;
      .address {
        font-size: 24px;
      }
    }
  }
}
.btn {
  margin: 0 auto;
  margin-top: 50px;
  width: 682px;
  height: 76px;
  background: #f9f3dd;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0px;
  // color: rgba(255, 255, 255, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  // transition: all 0.05s;
  user-select: none;
}
</style>
